package com.ad.nbi.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Utils {
public static String getIorString(String fileName){
		
		
		File file = new File(fileName);
        Reader reader = null;
        char[] tempchars = new char[5000];
        int charread = 0;
        StringBuffer iorStringBuffer = new StringBuffer();
        try {
			reader = new InputStreamReader(new FileInputStream(fileName));
			  // 读入多个字符到字符数组中，charread为一次读取字符数
	        while ((charread = reader.read(tempchars)) != -1) {
	            // 同样屏蔽掉\r不显示
	            if ((charread == tempchars.length)
	                    && (tempchars[tempchars.length - 1] != '\r')) {
	                System.out.print(tempchars);
	            } else {
	                for (int i = 0; i < charread; i++) {
	                    if (tempchars[i] == '\r') {
	                        continue;
	                    } else {
	                        iorStringBuffer.append(tempchars[i]);
	                    }
	                }
	            }
	        }
	        
	       
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return iorStringBuffer.toString().trim();
	}
}
